# 加载

from datasets import load_dataset, load_from_disk

# 在线加载数据
# dataset = load_dataset(
#     path="lansinuote/ChnSentiCorp",
#     split="train"
# )

dataset = load_from_disk(dataset_path=r"E:\ai\datasets\ChnSentiCorp")
print(dataset)

test_dataset = dataset["test"]
for data in test_dataset:
    print(data)
#转存为CSV格式
dataset["train"].to_csv(path_or_buf=r"D:\ai-note\learning\example\bert\data\ChnSentiCorp_train.csv")
dataset["test"].to_csv(path_or_buf=r"D:\ai-note\learning\example\bert\data\ChnSentiCorp_test.csv")
#加载csv格式数据
train_dataset = load_dataset(path="csv",
                            data_files=r"D:\ai-note\learning\example\bert\data\ChnSentiCorp_train.csv")

print(train_dataset)
